home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Files / XTND 1.3.6 / XTND Headers / XTNDPInterfaces / XTNDInterface.p next >
Encoding:
Text File  |  1992-02-24  |  10.8 KB  |  228 lines  |  [TEXT/MPS ]

  1. (************************************************************************
  2. *                                                                        *
  3. *    XTNDInterface.p                                                        *
  4. *                                                                        *
  5. *    Claris XTND Architecture application header file                    *
  6. *                                                                        *
  7. *    Copyright © 1989-91 Claris Corporation                                *
  8. *    All Rights Reserved                                                    *
  9. *                                                                        *
  10. ************************************************************************)
  11.  
  12. {$IFC UNDEFINED UsingIncludes}
  13. {$SETC UsingIncludes := 0}
  14. {$ENDC}
  15.  
  16. {$IFC NOT UsingIncludes}
  17.     UNIT XTNDInterface;
  18.     INTERFACE
  19. {$ENDC}
  20.  
  21. {$IFC UNDEFINED UsingXTNDInterface}
  22. {$SETC UsingXTNDInterface := 1}
  23.  
  24. {$I+}
  25. {$SETC XTNDIncludes := UsingIncludes}
  26. {$SETC UsingIncludes := 1}
  27. {$IFC UNDEFINED UsingTypes}
  28. {$I $$Shell(PInterfaces)Types.p}
  29. {$ENDC}
  30. {$IFC UNDEFINED UsingStandardFile}
  31. {$I $$Shell(PInterfaces)StandardFile.p}
  32. {$ENDC}
  33. {$SETC UsingIncludes := XTNDIncludes}
  34.  
  35.     CONST
  36.     { Defines for XTND Version }
  37.  
  38.         xtndVersion = 2;
  39.  
  40.     { Defines for file types }
  41.         xtndTranslatorFileType = 'Fltr';
  42.         
  43.     { Defines for resource types }
  44.         translatorDescription = 'FTYP';
  45.         textImportType        = 'FLTI';
  46.         textExportType        = 'FLTE';
  47.         pictImportType        = 'PFLT';
  48.  
  49.     { Flag values for translator characteristics which are set in TransDescribe and FTYP }
  50.         ftypIsSpecial        = $0001;
  51.         ftypHasPreferences    = $0002;    { Reserved for future use }
  52.         ftypNeedsResources    = $0004;
  53.         ftypWritesResources    = $0008;    { Reserved for future use }
  54.         ftypOnlyPreferences = $0010;    { Reserved for future use }
  55.         ftypIsLocalized        = $0020;
  56.  
  57.     { Type of translators to be included in list }
  58.         allowTypeMask        = $00FF;
  59.         allowText            = $0001;
  60.         allowGraphics        = $0002;    { Reserved for future use }
  61.         allowDataBase        = $0004;    { Reserved for future use }
  62.         allowPict            = $0008;
  63.         allowOtherTypes        = $0080;    { Reserved for future use }
  64.         allowAllTypes        = $00FF;
  65.  
  66.     { Use of translators to be included in list }
  67.         allowUseMask        = $FF00;
  68.         allowImport            = $0100;
  69.         allowExport            = $0200;
  70.         allowOtherUses        = $8000;    { Reserved for future use }
  71.         allowAllUses        = $FF00;
  72.  
  73.     { Error codes which the XTND System can return }
  74.  
  75.         badXTNDVersionErr    = -9991;
  76.         noTransMatchErr        = -9999;
  77.  
  78.     { Error codes which a translator can return }
  79.  
  80.         badImportFileErr    = 12;
  81.         translationCanceledErr = 32767;
  82.  
  83.     TYPE
  84.  
  85.         XTNDDlgHookProcPtr = ProcPtr; { XTNDDlgHook(item: INTEGER; theDialog: DialogPtr;
  86.                 mySFParamPtr: Ptr; VAR changedFlag: BOOLEAN; unusedParm: LONGINT); }
  87.         TransProcPtr = ProcPtr; { Translator(pb: ParamBlk); C;    (Note: this uses C calling conventions) }
  88.  
  89.     { The MatchInfo data stucture defines a single file type (and possibly creator type)}
  90.     {      that a translator can recognize.}
  91.         MatchInfo = RECORD
  92.             docCreator        : ResType;        { Document creator, eg 'MACA' - MacWrite }
  93.             docType            : ResType;        { Document type, eg 'WORD' - MacWrite    }
  94.             exactMatch        : BOOLEAN;        { If TRUE, Creator MUST match }
  95.             creatorAndTypeMask    : SignedByte;        { Flags telling which bytes of file & creator types matter }
  96.         END;
  97.  
  98.  
  99.     { The TransDescribe data stucture defines an import/export translator.  There is one }
  100.     { of these (corresponds to the 'FTYP' resource) for every import/export translator. }
  101.         TransDescrHandle = ^TransDescrPtr;
  102.         TransDescrPtr = ^TransDescribe;
  103.         TransDescribe = RECORD
  104.             version            : INTEGER;        { Version of this FTYP (currently 2) }
  105.             translatorType    : ResType;        { Type of translator (ie, 'PFLT' for pictures) }
  106.             codeResID        : INTEGER;        { Resource ID of translator code resource }
  107.             FDIFResID        : INTEGER;        { Resource ID of 'FDIF' (or -1 if none) }
  108.             numVersBytes    : INTEGER;        { Number of bytes for version check (zero if no check) }
  109.             versBytesOffSet    : LONGINT;        { Offset into file for version check }
  110.             versBytes        : PACKED ARRAY[0..15] of SignedByte; { Byte values we are looking for (max 16) }
  111.             appWDRefNum        : INTEGER;        { Internal XTND use only - WDRefNum of the directory containing the application folder }
  112.             unused1            : INTEGER;        { Reserved for future use - must be zero for this version }
  113.             pathLength        : INTEGER;        { Internal XTND use only - Number of times this file has been translated }
  114.             flags            : INTEGER;        { Flags for filter characteristics }
  115.                                                 { bit 0 - set if this filter won't work with All Available }
  116.                                                 { bit 1 - reserved for future use - must be zero for this version }
  117.                                                 { bit 2 - set if this filter must be able to read its resources }
  118.                                                 { bit 3 - 4 reserved for future use - must be zero for this version }
  119.                                                 { bit 5 - set if this filter is localized to a particular language }
  120.                                                 { bit 6 - 14 reserved for future use - must be zero for this version }
  121.                                                 { bit 15 - Used internally - must be zero for this version }
  122.             transIndex        : INTEGER;        { Internal XTND use only - Index of this translator in the list stored by the FINI }
  123.             resRefNum        : INTEGER;        { RefNum of resource fork of the translator file when open }
  124.             directoryID        : LONGINT;        { Directory ID of the folder containing the filter }
  125.             vRefNum            : INTEGER;        { Volume RefNum of volume which contains filter directory }
  126.             fileName        : Str31;            { Name of file if this is an external filter }
  127.             numMatches        : INTEGER;        { Number of Matches for this translator (0 means all files) }
  128.             matches            : ARRAY [0..9] of MatchInfo; { An ARRAY of all file matches for this translator }
  129.             name            : Str31;            { Description of translator - appears in pop-up menus }
  130.         END;
  131.  
  132.     { The XTND file parameter block.        }
  133.         SFParamPtr = ^SFParamBlock;
  134.         SFParamBlock = RECORD
  135.     { The following fields must be the same in this structure and MatchTranslatorBlock }
  136.             allowFlags        : LONGINT;                { --> Flags which indicate Translators to be used }
  137.             numStandard        : LONGINT;                { --> How many "standard" file types }
  138.             standard        : TransDescrPtr;        { --> Native file format information }
  139.             ioResult        : OSErr;                { <-- Errors reported through this variable }
  140.             chosenTranslator: INTEGER;                { <-> On input, number of translators supplied in theChosenTranslator; on output, chosen Translator number }
  141.             theChosenTranslator    : TransDescrPtr;    { <-> On input, Pointer to list of translators to build popup menu from (UseMyTransList must be true if you supply this list); on output, pointer to the Chosen Translator }
  142.         { End of common fields }
  143.             fileReply        : ^SFReply;                { <-- File information is returned through this pointer }
  144.             applicNativeType: ResType;                { --> Application native document file type, for use when library cannot be found }
  145.             XTNDDlogHook    : XTNDDlgHookProcPtr;    { --> Pointer to your SF dialog hook }
  146.             currentMenuItem    : INTEGER;                { <-- chosen menu item (GetFile) }
  147.             currentSaveItem    : INTEGER;                { <-- chosen menu item (PutFile) }
  148.             where            : Point;                { --> Top left corner of dialog, if zero, center on screen }
  149.             prompt            : StringPtr;            { --> Pascal string which is displayed on dialog }
  150.             buttonTitle        : StringPtr;            { --> Pascal string which replaces the "Open" or "Save" button }
  151.             origName        : StringPtr;            { --> Pascal string which is the original name in a PutFile }
  152.             dialogID        : INTEGER;                { --> Resource number of your dialog template }
  153.             SFFilterProc    : ModalFilterProcPtr;    { --> Pointer to your modal dialog filter proc }
  154.             showAllFiles    : BOOLEAN;                { --> TRUE if you want all files to be shown }
  155.             useMyTransList    : BOOLEAN;                { --> TRUE if you are using chosenTranslator and theChosenTranslator to input a list of translators to be used in creating the popup menu }
  156.             myFileFilter    : FileFilterProcPtr;    { --> Pointer to your SF Filter Proc }
  157.             Unused            : LONGINT;                { Reserved for future use, must be zero }
  158.         END;
  159.  
  160.     { This parameter block is used to find a translator to read a file.}
  161.     {    }
  162.         MatchTranslatorPtr = ^MatchTranslatorBlock;
  163.         MatchTranslatorBlock = RECORD
  164.         { The following fields must be the same in this structure and in XTNDParamBlock }
  165.             allowFlags        : LONGINT;            { --> Flags which indicate Translators to be used }
  166.             numStandard        : LONGINT;            { --> How many "standard" file types }
  167.             standard        : TransDescrPtr;    { --> Native file format information }
  168.             ioResult        : OSErr;            { <-- IO Result from XTND library }
  169.             chosenTranslator: INTEGER;            { <-> On input, number of translators supplied in theChosenTranslator; on output, chosen Translator number }
  170.             theChosenTranslator    : TransDescrPtr;{ <-> On input, Pointer to list of translators to build popup menu from (UseMyTransList must be true if you supply this list); on output, pointer to the Chosen Translator }
  171.     { End of common fields }
  172.             fileName        : StringPtr;        { --> File name }
  173.             vRefNum            : INTEGER;            { --> Volume Reference Number of file }
  174.             ioDirID            : LONGINT;            { --> Directory id of file }
  175.             initFlag        : BOOLEAN;            { --> TRUE if the list of translators should be rebuilt }
  176.             useTransList    : BOOLEAN;            { --> TRUE if you are using chosenTranslator and theChosenTranslator to input a list of translators to be used in creating the popup menu }
  177.             oneTrans        : TransDescrPtr;    { --> If this is supplied, it will be tried instead of searching all available translators }
  178.             unused            : ARRAY[0..3] of LONGINT;    { Reserved for future use, must be zero }
  179.         END;
  180.  
  181.         SelectParamPtr = ^SelectParamBlock;
  182.         SelectParamBlock = RECORD
  183.             translatorVersion: INTEGER;        { To select by translator type }
  184.             translatorType    : ResType;        { and version }
  185.             includeFlags    : LONGINT;        { Include any of these translator types }
  186.             excludeFlags    : LONGINT;        { Exclude all of these translator types }
  187.             includeTrans    : INTEGER;        { Include translators with any of these flags set }
  188.             excludeTrans    : INTEGER;        { Excluded translator with any of these flags set }
  189.             transName        : StringPtr;    { Include only translators with this name }
  190.             PBVersion        : LONGINT;        { ••• MUST be ONE (1) for this version ••• }
  191.             menuSortFlag    : BOOLEAN;        { TRUE if you want the list sorted and duplicates removed as when the XTND System creates a menu in XTNDGetFile or XTNDPutFile for you }
  192.             unused1            : BOOLEAN;        { Reserved for future use, must be zero }
  193.             unused2            : INTEGER;        { Reserved for future use, must be zero }
  194.             unused            : ARRAY[0..3] of LONGINT; { Reserved for future use, must be zero }
  195.         END;
  196.  
  197.     {     Routines available in XTNDLibrary    }
  198.     FUNCTION XTNDInitTranslators (transVersion: INTEGER; xtndSystemName, clarisFolderName: Str255): OSErr;
  199.  
  200.     FUNCTION XTNDGetFile (paramPtr: SFParamPtr): BOOLEAN;
  201.  
  202.     FUNCTION XTNDPutFile (paramPtr: SFParamPtr): BOOLEAN;
  203.  
  204.     FUNCTION XTNDLoadTranslator (theTranslator: TransDescrPtr; var transResource: TransProcPtr): OSErr;
  205.  
  206.     FUNCTION XTNDReleaseTranslator (theTranslator: TransDescrPtr): OSErr;
  207.  
  208.     PROCEDURE XTNDCloseTranslators;
  209.  
  210.     FUNCTION XTNDRebuildTransList: OSErr;
  211.  
  212.     FUNCTION XTNDSelectTranslators (selectPtr: SelectParamPtr; transHandle: TransDescrHandle): OSErr;
  213.  
  214.     FUNCTION XTNDMatchFile (matchPtr: MatchTranslatorPtr): BOOLEAN;
  215.  
  216.     PROCEDURE XTNDCallTranslator (theParamBlock: UNIV Ptr; theProc: TransProcPtr);
  217.     INLINE
  218.         $205F,             {     MOVE.L    (SP)+,A0    ;    get translator address off stack }
  219.         $4E90,            {    JSR        (A0)        ;    Call it }
  220.         $584F;            {    ADDQ    #4,A7        ;    Adjust the stack (C calling conventions) }
  221.  
  222.  
  223. {$ENDC}
  224.     { UsingXTNDInterface }
  225.  
  226. {$IFC NOT UsingIncludes}
  227.     END.
  228. {$ENDC}